home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
wais
/
ftw
/
scantest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-09
|
731b
|
44 lines
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "pdftw.h"
extern int alphasort();
static int
filesonly(e)
struct dirent *e;
{
struct stat sb;
return(stat(e->d_name, &sb) >= 0 && (sb.st_mode & S_IFMT) == S_IFREG);
}
main(ac, av)
int ac;
char *av[];
{
register int i;
register int j;
struct dirent **list;
if (ac != 2) {
fprintf(stderr, "usage: %s dirname\n", av[0]);
exit(1);
}
if (chdir(av[1]) < 0) {
perror(av[1]);
exit(1);
}
if ((i = scandir(".", &list, filesonly, alphasort)) < 0) {
perror("Error reading directory");
exit(1);
}
for (j = 0; j < i; j++)
printf("%s\n", list[j]->d_name);
for (j = 0; j < i; j++)
free((char *)list[j]);
free((char *)list);
exit(0);
}